<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>部门管理</title>
<script type="text/javascript" src="../static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
<link rel="stylesheet" href="../webjars/bootstrap/3.3.7-1/css/bootstrap.css" >
<link rel="stylesheet" href="../static/jquery-easyui-1.5.5.3/themes/material-teal/easyui.css" />
<link rel="stylesheet" href="../static/jquery-easyui-1.5.5.3/themes/icon.css" />
<link rel="stylesheet" href="../static/custom.css"/>
<script type="text/javascript" src="../static/jquery-easyui-1.5.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/jquery-easyui-1.5.5.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../webjars/bootstrap/3.3.7-1/js/bootstrap.js"></script>
<script type="text/javascript" src="../static/custom.js"></script>
<script type="text/javascript">
$(function(){
	$('#t_dept').treegrid({
		idField:'id',
		treeField:'name',
		title:'部门列表',
		singleSelect: true ,
		fitColumns:true,
		url:'list',
		columns:[
			[
				{field : 'id',title : 'ID',hidden:true},
				{field : 'name',title : '部门名称',width:200},
				{field : 'manager',title : '部门负责人',width:200}
			]
		],
		dialog:{
			create:{
				href:'edit',
				action:'save'
			},
			update:{
				href:'edit',
				action:'save'
			},
			delete:{
				href:'delete'				
			}
		},
		toolbar:[{
			text:'新增',
			iconCls:'icon-add',
			handler:function(){
				var $grid=$('#t_dept');
				var $row=$grid.treegrid('getSelected');
				//var $query=row?{parentId:$row.id}:{};
				//创建一个层 编辑用
				var $dialog=('<div/>');
				//把层丢到body上去  父节点
				$dialog.appendTo($grid.parent());
				//取grid的参数
				$dlg=$grid.treegrid('options').dialog;
				//让我们把几个对象拼成一个，后面的可以覆盖前面的
				//取对象的值，是否为空
				var $param = $.extend({
					//如果为空，给默认值
					title:'新增窗口',
					width:260,
					href:'edit',
					modal:true,
					grid:$grid,
					queryParams:$query,
					onClose:function(){
						$dialog.dialog('destroy');
					},
					buttons:[$.dialog.buttons.save,$.dialog.buttons.reset,$.dialog.buttons.close]
				},$dlg&&$dlg.create?$dlg.create:{});
				$dialog.dialog.params;
			}
		},'-',
		$.crudgrid.buttons.update,'-',
		$.crudgrid.buttons.delete,'-',
		$.crudgrid.buttons.reload]
		
	});
});
</script>
</head>
<body>
<table id="t_dept"></table>
</body>
</html>